﻿using J.Model;
using J.ProductSet.Application.Command.AggregateCommodityCommand;
using MediatR;
using SqlSugar;

namespace J.ProductSet.Application.CommandHandler.AggregateCommodityCommandHandler
{
    public class AggregateDeleteCommandHandler : IRequestHandler<AggregateDeleteCommand, int>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public AggregateDeleteCommandHandler(ISqlSugarClient sqlSugarClient)
        {
            _sqlSugarClient = sqlSugarClient;
        }

        public async Task<int> Handle(AggregateDeleteCommand request, CancellationToken cancellationToken)
        {

            var id = request.AggregateID.Split(",");
            var list = await _sqlSugarClient.Deleteable<AggregateCommodity>(id).ExecuteCommandAsync();
            return list;
        }
    }
}
